package edu.tum.cs.stageflow.benchmarkapplications.bigData;

import java.io.FileNotFoundException;

import sun.misc.JavaAWTAccess;

import com.scireum.open.xml.StructuredNode;

import edu.tum.cs.stageflow.executionframework.Flow;

public class WikiNodeHandlerExecutor {
	public static void main(String[] args) {
		WikiNodeHandler nodeHandler = null;
		Flow dataFlow = new Flow<StructuredNode>();
		
		System.out.println("Start Input Thread");
		try {
			nodeHandler = new WikiNodeHandler(dataFlow);
			nodeHandler.start();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("Start Network");
		
		if(nodeHandler != null) {
			WikiSearch wikiSearch = new WikiSearch(dataFlow);
			wikiSearch.getRunner().start();
		}
		else {
			System.out.println("WHY NOT?");
		}
		System.out.println("Network running...");
		
		try {
			nodeHandler.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		synchronized (dataFlow) {
			dataFlow.setFinished(true);
			dataFlow.notifyAll();
		}

		System.out.println("Network finished");
		
	}
}
